package lesson2.tests;

import lesson2.api.models.UserData;

import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class LoginTest extends TestBase
{
	@BeforeMethod
	public void logout()
	{
		pageHelper().logout();
	}

	@Test
	public void loginWithDataTest()
	{
		UserData userData = new UserData();
		userData.login = "babar";
		userData.password = "111111";

		navigationHelper().openIndexPage();
		pageHelper().indexPage().fillLoginData(userData);
		pageHelper().indexPage().submitLoginData();

		Assert.assertTrue(pageHelper().isLoggedIn(), "User is not logged in");
	}

	@Test
	public void loginWithoutDataTest()
	{
		UserData userData = new UserData();
		userData.login = "";
		userData.password = "";

		navigationHelper().openIndexPage();
		pageHelper().indexPage().fillLoginData(userData);
		pageHelper().indexPage().submitLoginData();

		Assert.assertFalse(pageHelper().isLoggedIn(), "User is logged in");
	}

}